/*************************************************************************/
/*								  	 */
/*	Routine for printing confusion matrices				 */
/*	---------------------------------------				 */
/*								  	 */
/*************************************************************************/

#include "defns.i"
#include "types.i"
#include "extern.i"


void PrintConfusionMatrix(ItemNo *ConfusionMat)
{
    short Row, Col;

    if ( MaxClass > 20 ) return;  /* Don't print nonsensical matrices */

    /*  Print the heading, then each row  */

    vecstrOutput.push_back(_T("\n\n\t"));
    ForEach(Col, 0, MaxClass)
    {
		strTemp0.Format(_T("  (%c)"), 'a' + Col);
	vecstrOutput.push_back(strTemp0);
    }

    vecstrOutput.push_back(_T("\t<-classified as\n\t"));
    ForEach(Col, 0, MaxClass)
    {
	vecstrOutput.push_back(_T(" ----"));
    }
    vecstrOutput.push_back(_T("\n"));

    ForEach(Row, 0, MaxClass)
    {
	vecstrOutput.push_back(_T("\t"));
	ForEach(Col, 0, MaxClass)
	{
	    if ( ConfusionMat[Row*(MaxClass+1) + Col] )
	    {
			strTemp0.Format(_T("%5d"), ConfusionMat[Row*(MaxClass+1) + Col]);
		vecstrOutput.push_back(strTemp0);
	    }
	    else
	    {
		vecstrOutput.push_back(_T("     "));
	    }
	}
	strTemp0.Format(_T("\t(%c): class "), 'a' + Row);
	strTemp1=ClassName[Row];
	vecstrOutput.push_back(strTemp0+strTemp1+_T("\n"));
    }
    vecstrOutput.push_back(_T("\n"));
}
